package com.example.mobile2021606128wje0417;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class SchoolAdapter extends RecyclerView.Adapter<SchoolAdapter.ViewHolder>{
    String[] schools;
    public SchoolAdapter(String[] schools){
        this.schools=schools;
    }

    static class ViewHolder extends RecyclerView.ViewHolder{
        TextView tvItemSchool;
        public ViewHolder(View itemView){
            super(itemView);
            tvItemSchool =itemView.findViewById( R.id.tv_item_school );
    }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from( parent.getContext() ).inflate( R.layout.item_rv_main_schools,parent,false );
        ViewHolder viewHolder = new ViewHolder( view );
     return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvItemSchool.setText( schools[position] );

    }

    @Override
    public int getItemCount() {
        return schools.length;
    }
}
